package com.cn.ryc.controller;

import com.cn.ryc.service.VideoService;
import com.cn.ryc.util.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/api/video")
public class VideoController {

    @Autowired
    private VideoService videoService;

    @PostMapping("/insert")
    public ResponseEntity<ApiResponse<String>> insertVideoInfo(@RequestBody Map<String, Object> request) {
        String videoUrl = (String) request.get("videoUrl");
        String videoName = (String) request.get("videoName");
        String uploadTime = (String) request.get("uploadTime");
        Long userId = Long.valueOf(request.get("userId").toString());
        String fileSize = (String) request.get("fileSize");

        return videoService.insertVideoInfo(videoUrl, videoName, uploadTime, userId, fileSize);
    }
}